import { request } from "@/utils/http";
import { Key } from "react";
import {
  getHospitalSetListParamsType,
  getHospitalSetListType,
  addHospitalSetListParams,
  getHospitalSetListRecordItemType,
  updateHospitalByIdType,
} from "./model/hospitalSetType";

//医院设置中，获取医院列表请求
export const getHospitalSetListRequire = ({
  page,
  limit,
  hosname,
  hoscode,
}: getHospitalSetListParamsType) => {
  return request.get<any, getHospitalSetListType>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      params: {
        hosname,
        hoscode,
      },
    }
  );
};

//医院设置中，添加医院请求
export const addHospitalSetListRequire = (data: addHospitalSetListParams) => {
  // console.log(data);
  return request.post<any, null>("/admin/hosp/hospitalSet/save", data);
};

//发送请求，根据医院id的值获取医院的详细信息
export const getHospitalByIdRequest = (id: string) => {
  return request.get<any, getHospitalSetListRecordItemType>(
    `/admin/hosp/hospitalSet/get/${id}`
  );
};

//发送请求，修改获取医院信息的值
export const updateHospitalByIdRequire = (data: updateHospitalByIdType) => {
  // console.log(data);
  return request.put<any, null>("/admin/hosp/hospitalSet/update", data);
};

//发送请求,删除单个医院
export const deleteHospitalRequest = (id: number) => {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`);
};

//发送请求,删除全部数据
export const batchDeleteHospitalRequest = (ids: Key[]) => {
  // console.log("ids", ids);
  return request.delete("/admin/hosp/hospitalSet/batchRemove",{
    data:ids
  })
};
